package com.tvunetworks.center.device.util;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * @program: tvucc-aggregator
 * @author lebronchen
 * @param <T>  t
 * @create: 2020-02-19 12:46
 **/
public class PageBar<T> implements Serializable {
	private static final long serialVersionUID = 8070566027198912646L;
	private long totalPageNum = 0;// 共有页面数目
	private long currentPageNum = 1;// 当前现实的页面数
	private List<T> resultList = new ArrayList<T>();// 结果
	private long everyPageNum = 10;// 每页显示数据的条
	private long totalNum = 0;// 共有数据数目
	private Map<String, String> paraMap = null;
	private Object otherObject;
	private String url = "";
	private String userflag;
	private String receiverList = "";// receiverList
	private String bookmarkList = "";
	private String sentNum;

	public PageBar() {
        super();
    }

	/**
	 *
	 * @param para para
	 */
    public PageBar(Map<String, String> para) {
		this.setCurrentPageNum(para.get("currentPageNum"));
		this.setEveryPageNum(para.get("everyPageNum"));
	}

	/**
	 *
	 * @param currentPageNum currentPageNum
	 * @param everyPageNum everyPageNum
	 */
	public PageBar(String currentPageNum, String everyPageNum) {
        this.setCurrentPageNum(currentPageNum);
        this.setEveryPageNum(everyPageNum);
    }

	/**
	 *
	 * @param currentPageNum currentPageNum
	 * @param everyPageNum everyPageNum
	 */
	public PageBar(long currentPageNum, long everyPageNum) {
	    this.setCurrentPageNum(currentPageNum);
	    this.setEveryPageNum(everyPageNum);
	}

	/**
	 *
	 * @param para para
	 */
	public void initPara(Map<String, String> para) {
	    this.setCurrentPageNum(para.get("currentPageNum"));
	    this.setEveryPageNum(para.get("everyPageNum"));
	}

	public long getCurrentPageNum() {
		return currentPageNum;
	}

	/**
	 *
	 * @param currentPageNum currentPageNum
	 */
	public void setCurrentPageNum(String currentPageNum) {
		if (null == currentPageNum || "".equals(currentPageNum)){

			currentPageNum = "1";
		}
		this.currentPageNum = Long.parseLong(currentPageNum);
	}

	public long getEveryPageNum() {
		return everyPageNum;
	}

	/**
	 *
	 * @param everyPageNum everyPageNum
	 */
	public void setEveryPageNum(String everyPageNum) {
		if (null == everyPageNum || "".equals(everyPageNum)){

			everyPageNum = "10";
		}
		this.everyPageNum = Long.parseLong(everyPageNum);
		;
	}

	public List<T> getResultList() {
		return resultList;
	}

	public void setResultList(List<T> resultList) {
		this.resultList = resultList;
	}

	public long getTotalPageNum() {
		return totalPageNum;
	}

	public void setTotalPageNum(long totalPageNum) {
		this.totalPageNum = totalPageNum;
	}

	public long getTotalNum() {
		return totalNum;
	}

	/**
	 *
	 * @param totalNum totalNum
	 */
	public void setTotalNum(long totalNum) {
		this.totalNum = totalNum;
		this.totalPageNum = totalNum / (double)everyPageNum < (double) totalNum
				/ (double)everyPageNum ? ((totalNum / everyPageNum) + 1) : totalNum
				/ everyPageNum;
	}

	public Map<String, String> getParaMap() {
		return paraMap;
	}

	public void setParaMap(Map<String, String> paraMap) {
		this.paraMap = paraMap;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Object getOtherObject() {
		return otherObject;
	}

	public void setOtherObject(Object otherObject) {
		this.otherObject = otherObject;
	}

	public String getUserflag() {
		return userflag;
	}

	public void setUserflag(String userflag) {
		this.userflag = userflag;
	}

	/** 
	 * receiverList. 
	 * 
	 * @return  the receiverList 
	 * @since   JDK 1.7 
	 */
	public String getReceiverList() {
		return receiverList;
	}

	/** 
	 * receiverList. 
	 * 
	 * @param   receiverList    the receiverList to set 
	 * @since   JDK 1.7 
	 */
	public void setReceiverList(String receiverList) {
		this.receiverList = receiverList;
	}

	/** 
	 * bookmarkList. 
	 * 
	 * @return  the bookmarkList 
	 * @since   JDK 1.7 
	 */
	public String getBookmarkList() {
		return bookmarkList;
	}

	/** 
	 * bookmarkList. 
	 * 
	 * @param   bookmarkList    the bookmarkList to set 
	 * @since   JDK 1.7 
	 */
	public void setBookmarkList(String bookmarkList) {
		this.bookmarkList = bookmarkList;
	}

	public String getSentNum() {
		return sentNum;
	}

	public void setSentNum(String sentNum) {
		this.sentNum = sentNum;
	}
    
    public void setCurrentPageNum(long currentPageNum) {
        this.currentPageNum = currentPageNum;
    }
    
    public void setEveryPageNum(long everyPageNum) {
        this.everyPageNum = everyPageNum;
    }
	
}
